/*************
 *  查询类型及状态
 */
package com.yy.ttmodule.cardStatus;

import android.util.Log;

/**
 * Created by wujun on 17-8-30.
 */

public class StatusBean {
    //改这些会影响positionToName,updateName, BmChecker.updateId
    public static final int TYPE_CF_CARD = 0x01;
    public static final int TYPE_BM_BAR = 0x02;
    public static final int TYPE_CP   = 0x03;
    public static final int TYPE_SIM  = 0x04;
    public static final int TYPE_GPS = 0x05;
    public static final int TYPE_BATTERY = 0x06;

    public static final int TYPE_CF_MODE = 0x07;
    public static final int TYPE_CF_POWER_ON = 0x08;

    public static final String KEY_CF_CARD = "CfCard";
    public static final String KEY_BM_BAR = "BmBar";
    public static final String KEY_CP = "cp";
    public static final String KEY_SIM = "sim";
    public static final String KEY_GPS = "gps";
    public static final String KEY_BATTERY = "battery";

    public static final String KEY_CF_MODE = "CfMode";
    public static final String KEY_CF_POWER_ON = "CfPowerOn";

    public static final int STATUS_ERROR = -1;
    public static final int STATUS_OK = 0;
    public static final int STATUS_CHECKING = 1;
    private static final String TAG = "StatusBean";

    private int mType;
    private int mStatus;

    public String getName() {
        return mName;
    }

    private String mName = "";

    /**
     * @return
     */
    public int getResIdDetail() {
        return mResIdDetail;
    }

    int mResIdDetail;

    /**
     * @param type
     */
    public StatusBean(int type) {
        this.mType = type;
        this.mStatus = STATUS_CHECKING;
        updateName();
    }

    /**
     * @param type
     * @param resIdDetail
     */
    public StatusBean(int type, int resIdDetail) {
        this.mType = type;
        this.mStatus = STATUS_CHECKING;
        this.mResIdDetail = resIdDetail;
        updateName();
    }

    /**
     * 
     */
    private void updateName() {
        switch (mType){
            case TYPE_CF_CARD:{
                mName = KEY_CF_CARD;
                break;
            }
            case TYPE_BM_BAR:{
                mName = KEY_BM_BAR;
                break;
            }
            case TYPE_CP:{
                mName = KEY_CP;
                break;
            }
            case TYPE_SIM:{
                mName = KEY_SIM;
                break;
            }
            case TYPE_GPS:{
                mName = KEY_GPS;
                break;
            }
            case TYPE_BATTERY:{
                mName = KEY_BATTERY;
                break;
            }
            case TYPE_CF_MODE:{
                mName = KEY_CF_MODE;
                break;
            }
            case TYPE_CF_POWER_ON:{
                mName = KEY_CF_POWER_ON;
                break;
            }
        }
    }

/*    public StatusBean(int type, int status) {
        mType = type;
        mStatus = status;
        updateName();
    }*/

    /**
     * @return
     */
    public int getType() {
        return mType;
    }

    /**
     * @param type
     */
    public void setType(int type) {
        mType = type;
    }

    /**
     * @return
     */
    public synchronized int getStatus() {
        return mStatus;
    }

    /**
     * @param status
     */
    public synchronized void setStatus(int status) {
        mStatus = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if ((o == null) || (getClass() != o.getClass())) {
            return false;
        }

        StatusBean that = (StatusBean) o;

        if (mType != that.mType) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int result = mType;
        result = 31 * result + 0x101;
        Log.i(TAG, "mType=" + mType + ", result=" + result);
        return result;
    }

    @Override
    public String toString() {
        return "StatusBean{" +
                "mType=" + mType +
                ", mStatus=" + mStatus +
                '}';
    }

    /**
     * @param position
     * @return
     */
    public static String positionToName(int position) {
        int type = position + 1;

        switch (type) {
            case TYPE_CF_CARD:{
                return KEY_CF_CARD;
            }
            case TYPE_BM_BAR:{
                return KEY_BM_BAR;
            }
            case TYPE_CP:{
                return KEY_CP;
            }
            case TYPE_SIM:{
                return KEY_SIM;
            }
            case TYPE_GPS:{
                return KEY_GPS;
            }
            case TYPE_BATTERY:{
                return KEY_BATTERY;
            }
        }
        return "";
    }

}
